package com.jt.sys.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jt.common.vo.JsonResult;
import com.jt.sys.entity.SysDept;
import com.jt.sys.service.SysDeptService;
@Controller
@RequestMapping("/dept/")
public class SysDeptController {
	@Autowired
	private SysDeptService sysDeptService;
	@RequestMapping("doDeptListUI")
	public String doDeptListUI(){
		return "sys/dept_list";
	}
	@RequiresPermissions("sys:dept:add")
	@RequestMapping("doDeptSaveEditUI")
	public String doDeptSaveEditUI(){
		return "sys/dept_edit";
	}
	@RequiresPermissions("sys:dept:update")
	@RequestMapping("doDeptUpdateEditUI")
	public String doDeptUpdateEditUI(){
		return "sys/dept_edit";
	}
	@RequestMapping("doFindObjects")
	@ResponseBody
	@RequiresPermissions("sys:dept:view")
	public JsonResult doFindObjects(){
		List<SysDept> sysDepts = sysDeptService.findObjects();
		return new JsonResult(sysDepts);
	}
	@RequestMapping("doDeleteObject")
	@ResponseBody
	@RequiresPermissions("sys:dept:del")
	public JsonResult doDeleteObject(Integer id){
		sysDeptService.deleteObjectById(id);
		return new JsonResult("delete OK");
	}
	
	@RequestMapping("doSaveObject")
	@ResponseBody
	//@RequiresPermissions("sys:dept:add")
	public JsonResult doSaveObject(SysDept entity){
		sysDeptService.saveObject(entity);
		return new JsonResult("save ok");
	}
	
	@RequestMapping("doFindZTreeNodes")
	@ResponseBody
	public JsonResult doFindZTreeNodes(){
		return new JsonResult(
		sysDeptService.findZTreeDeptNodes());
	}
	@RequestMapping("doUpdateObject")
	@ResponseBody
	//@RequiresPermissions("sys:dept:update")
	public JsonResult doUpdateObject(SysDept entity){
		sysDeptService.updateObject(entity);
		return new JsonResult("update ok");
	}
}
